<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="image" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="popProductPictureAdd('')" type='success' size="mini"><i class='fa fa-plus'></i>增加图片</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 图片列表 </span>
          </div>
          <el-table :data="image">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="d_file('&file_id='+scope.row.file_id+'')">移除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="" prop="product_id">
              <template slot-scope="scope">
                <el-link @click="gotoPage('E66EAEFA14EE4C7AA552D511AAC9B4F1?&CMID='+scope.row.product_id+''+vueparams+'')" type='primary'><img class='link4_mouseout' src='images/icons/talent/nopic.jpg' width='80' height='80' /></el-link>
              </template>
            </el-table-column>
            <el-table-column label="产品名称" prop="p_name">
            </el-table-column>
            <el-table-column label="图片类型" prop="file_typeid">
            </el-table-column>
            <el-table-column label="图片名称" prop="file_name">
            </el-table-column>
            <el-table-column label="日期" prop="cdate">
            </el-table-column>
            <el-table-column label="" prop="">
              <template slot-scope="scope">
                <el-link @click="u_file('&CMID2='+scope.row.file_id+'')" type='primary'>网站显示</el-link>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'产品图片'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
    <el-dialog :visible.sync="ProductPictureAddVisible" append-to-body>
      <ProductPictureAdd v-if="ProductPictureAddVisible" ref="ProductPictureAdd" :popparams="popparams"> </ProductPictureAdd>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ProductPictureAdd from "@/views/psi/product/ProductPictureAdd";
  export default {
    name: 'ProductPicture',
    components: {
      ProductPictureAdd,
    },
    props: ['popparams'],
    data() {
      return {
        ProductPictureAddVisible: false,
        ProductPictureAddValue: null,
        ProductPictureAddDesc: null,
        vueparams: this.getVUEParams(""),
        image: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "C1BDE411EFF7473EAF5F658AF81F2689",
        name: "产品目录右菜单",
        selected: "产品图片"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/product/ProductAction/productPicture?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_file(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/product/ProductAction/d_file?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      u_file(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/product/ProductAction/u_file?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      popProductPictureAdd(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ProductPictureAddVisible = !this.ProductPictureAddVisible;
      },
    },
  }
</script>
